﻿ /*************************************************************************
File:   as/var_frame1.as
Author: Duykham
UpDate: 15/09/2006
TODO:   Khai bao tat ca cac bien trong frane 1
/*************************************************************************/
echo ("#included: var_frame1_S1.as");
///////////////////////////////////////////////////////////////////////////
//TODO: include files

///////////////////////////////////////////////////////////////////////////
//TODO:ExternalInterface
import flash.external. *;
///////////////////////////////////////////////////////////////////////////
//TODO: Setup External method to be called outside of Flash
var methodSetup : Boolean = ExternalInterface.addCallback ("syncCam", null, syncCam);
///////////////////////////////////////////////////////////////////////////
//TODO:Khai bao bien
var camList_cb : mx.controls.ComboBox;
//Danh sach Cameras hien thi trong ComboBox
var camPreview = new Camera ();
var changeCamListener : Object = new Object ();
var numberOfCams : Number = new Number ();
//so cam da duoc cai dat vao he thong
var camDetectedArray : Array = new Array ();
//mang nay luu tru cac Cam tim thay trong he thong
var camArray = new Array ();
//mang nay luu tru cac Cam hoat dong (sau khi so sanh voi mang do VB truyen sang)
var soCam : Number = 0;
/*
var rsoCameras;
//Tao ShareObject cho cac cams
myConnection = new NetConnection ();
myConnection.connect (_root.CFG.fmsApp);
rsoCameras = SharedObject.getRemote ("cams/" + clock.strDate, myConnection.uri, true);
rsoCameras.connect (myConnection);
*/
///////////////////////////////////////////////////////////////////////////
//TODO:Initialize
camDetectedArray = Camera.names;
numberOfCams = camDetectedArray.length;
//detect so cam da duoc tim thay trong he thong

function syncCam ()
{
	echo ("syncCam");
	camDetectedArray = Camera.names;
	numberOfCams = camDetectedArray.length;
	for (var i = 0; i < numberOfCams; i ++)
	{
		for (var j = 0; j < soCamVB; j ++)
		{
			if (camDetectedArray [i] == camArrayVB [j].data )
			{
				camArray.push (
				{
					label : camArrayVB [j].label, data : i, displayName : camArrayVB [j].displayName, motion : camArrayVB [j].motion, priority : camArrayVB [j].priority	
				});
				echo ("camArrayVB [j].motion: " + camArrayVB [j].motion);
			}
		}
	}
	_root.soCam = camArray.length;
	echo ("soCam: " + soCam);
};
